<template>
    <el-form ref="form" label-width="80px" size="mini" label-position="left" style="margin: 20px">
        <el-form-item label="厂商名称">
            <el-input v-model="row.name"></el-input>
        </el-form-item>
        <el-form-item label="厂商描述">
            <el-input type="textarea" v-model="row.remarks" placeholder="请输入厂商描述"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="submit">保存</el-button>
            <el-button @click="close">取消</el-button>
        </el-form-item>
    </el-form>
</template>
<script>
import C from '#/src/common/common.js'

export default {
    name: 'addFactory',
    data () {
        return {
            row: {
                id: 0,
                name: '',
                remarks: '',
            }
        }
    },
    methods: {
        async submit () {

            if (this.row.name == '') {
                C.error('请输入厂商名称')
                return false
            }

            let data = await C.ajax('/organization/factory/addedit', this.row, 'post')
            if (data) {
                C.closeBrowserWindow(data)
            }
        },
        close () {
            C.closeBrowserWindow()
        }
    },
    mounted: function () {
        let row = C.getDatas()
        if (row && row.id) {
            this.row.id = row.id
            this.row.name = row.name
            this.row.remarks = row.remarks
        }
    }
}
</script>